package gemini.basic.model;
// default package
// Generated Nov 23, 2010 4:23:01 PM by Hibernate Tools 3.4.0.Beta1

import static javax.persistence.GenerationType.IDENTITY;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Version;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 * Order generated by hbm2java
 */
@Entity
@Table(name = "g_order", catalog = "gemini")
public class Order extends AbstractDomain implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	
	private Integer id;
	private Integer version;
	private Product product;
	private Cart cart;
	private String typeCode;
	private short quantity;
	private ReturnOrder returnOrder;
	private List<OrderStatus> orderStatuses = new ArrayList<OrderStatus>(0);
	private BuyOrder buyOrder;
	private RenewOrder renewOrder;

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@Version
	@Column(name = "version")
	public Integer getVersion() {
		return this.version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "product_id", nullable = false)
	public Product getProduct() {
		return this.product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "cart_id", nullable = false)
	public Cart getCart() {
		return this.cart;
	}

	public void setCart(Cart cart) {
		this.cart = cart;
	}

	@Column(name = "type_code", nullable = false, length = 3)
	public String getTypeCode() {
		return this.typeCode;
	}

	public void setTypeCode(String typeCode) {
		this.typeCode = typeCode;
	}

	@Column(name = "quantity", nullable = false)
	public short getQuantity() {
		return this.quantity;
	}

	public void setQuantity(short quantity) {
		this.quantity = quantity;
	}

	@OneToOne(fetch = FetchType.LAZY, mappedBy = "order")
	public ReturnOrder getReturnOrder() {
		return this.returnOrder;
	}

	public void setReturnOrder(ReturnOrder returnOrder) {
		this.returnOrder = returnOrder;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "order")
	@Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE})
	public List<OrderStatus> getOrderStatuses() {
		return this.orderStatuses;
	}

	public void setOrderStatuses(List<OrderStatus> orderStatuses) {
		this.orderStatuses = orderStatuses;
	}

	@OneToOne(fetch = FetchType.LAZY, mappedBy = "order")
	public BuyOrder getBuyOrder() {
		return this.buyOrder;
	}

	public void setBuyOrder(BuyOrder buyOrder) {
		this.buyOrder = buyOrder;
	}

	@OneToOne(fetch = FetchType.LAZY, mappedBy = "order")
	public RenewOrder getRenewOrder() {
		return this.renewOrder;
	}

	public void setRenewOrder(RenewOrder renewOrder) {
		this.renewOrder = renewOrder;
	}
}
